<!DOCTYPE html>
<html lang="zh-cn">
	
<style type="text/css">
    	#preview{
width:100px;
height:100px;
margin:20px auto;
cursor: pointer;
}
    </style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="css/pintuer.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jquery-2.1.0.js"></script>
<script src="js/pintuer.js"></script>
<script src="js/ajaxfileupload.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/util.js"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>增加教师</strong></div>
  <div class="body-content">
    <form class="form-x" id="form">
        <input  id="id" type="hidden" name="id">
      <div class="form-group">
        <div class="label">
          <label>姓名：</label>
        </div>
        <div class="field">
          <input  id="name" type="text" class="input w50" value="" name="name" data-validate="required:请输入姓名" />
          <div class="tips"></div>
        </div>
      </div>

      


        
         <div class="form-group">
          <div class="label">
            <label>年龄：</label>
          </div>
          <div class="field">
              <input  id="age" type="text" class="input w50" value="" name="age" data-validate="required:请输入年龄" />
              <div class="tips"></div>
            <div class="tips"></div>
          </div>
        </div>
        
      <div class="form-group">
        <div class="label">
          <label>部门：</label>
        </div>
        <div class="field">
            <input id="did"  type="text" class="input w50" value="" name="did" data-validate="required:请输入部门" />
            <div class="tips"></div>
        </div>
      </div>
     
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
         <input  class="button bg-main icon-check-square-o"  style="text-align: center;"  type="button" name="back" value="确定提交" onclick="adduser()"/>
        </div>
      </div>
    </form>
  </div>
</div>

</body>

<script>
    $(function(){
        var id = (window.location.href).split("?")[1];
        $.ajax({
            type: "post",
            url: baseUrl+"/user/edit",
            data : {"id":id},
            dataType:"json",
            success: function (res) {
                $("#id").val(res.id)
                $("#name").val(res.name)
                $("#age").val(res.age)
                $("#did").val(res.did)

            }
        })
    })
    function adduser() {

        $.ajax({
            type: "post",
            url: baseUrl+"/user/add",
            data: $("#form").serialize(),
            success: function (res) {
                if(res == '1'){
                    window.location.href =baseUrl+"/user/list.html";
                }
            }
        })
    }
</script>


</html>